<template>
  <div>
    <div>tom:{{ count }}</div>
    <button @click="add">+1</button>
  </div>

</template>

<script>
import bus from '../../../utils/eventBus.js'
export default {
  data() {
    return {
    }
  },
  computed: {
    count() {
      return this.$store.state.tomCount
    }
  },
  mounted() {
    bus.$on('add-tom', (data) => {
      this.count += data
    })
  },
  methods: {
    add() {
      // bus.$emit('add-jerry', 1)
      this.$store.commit('addJerry', 1)
    }
  }
}
</script>

<style>

</style>
